package com.bwsoft.action;

import java.util.List;

import org.apache.log4j.Logger;

import com.bwsoft.domain.User;
import com.bwsoft.model.ComBoBox;

public class SystemAction extends BaseAction {

	private static final long serialVersionUID = 4061899259350068887L;
	private static Logger log = Logger.getLogger(SystemAction.class.getClass());

	/**
	 * 用户登录
	 */
	public String userLogin() {

		// 表单验证
		if (user.getAccount().isEmpty() || user.getAccount() == null) {
			msg.msgStr = "用户名不能为空！";
			return "loginError";
		}
		if (user.getPassword().isEmpty() || user.getPassword() == null) {
			msg.msgStr = "登陆密码不能为空！";
			return "loginError";
		}

		// 得到当前用户登录的状态值
		msg = userService.checkUserLogin(user);
		if (msg.getMsgFlag()) {
			return "loginSuccess";
		} else {
			return "loginError";
		}
	}

	/**
	 * 页面初始化信息
	 */
	public String initIndex() {
		user = (User) session.get("User");
		log.info("初始化用户【" + user.getName() + "】系统页面");
		// 获取用户的系统菜单
		msg = systemService.getUserMenu(user);
		return "index";
	}

	public String logoutSyste() {

		session.clear();

		return "logoutSyste";
	}
	
	
	public String dictionaryJson(){
		List<ComBoBox> coms=systemService.getDictionary(comBoBox);
		responseListJson=coms;
		return "listJsonResult";
	}

}
